<template>
  <div class="history">
    <div class="title">
      <i class="iconfont icon-xiangzuo" @click="$router.go(-1), change()"></i>
      <div class="story">阅历</div>
    </div>

    <div class="historyContent">
      <div class="tileCon">
        我已读过 <span>{{ mes.length }}</span> 本书
      </div>
      <ul>
        <li
          v-for="item in mes"
          :key="item.id"
          @click="$router.push({ name: 'synopsis', query: { id: item.id } })"
        >
          <div class="date">{{ date }}</div>
          <div class="hisBox">
            <div class="img">
              <img :src="item.img" />
            </div>
            <div class="hiscont">
              <h1>{{ item.title }}</h1>
              <p>{{ item.writer }}</p>
              <p>
                {{ item.synopsis }}
              </p>
            </div>
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      mes: [],
      date:
        new Date().getFullYear() +
        "-" +
        (new Date().getMonth() + 1) +
        "-" +
        new Date().getDate(),
    };
  },
  methods: {
    change() {
      this.$emit("getnavs-btn", true);
    },
  },
  created() {
    this.$emit("getnavs-btn", false);
    this.mes = JSON.parse(localStorage.getItem("history"));
    // console.log(this.mes);
  },
};
</script>

<style lang="less">
.history {
  .title {
    position: fixed;
    width: 100%;
    min-height: 50px;
    display: flex;
    background-color: #fff;
    z-index: 1;
    i {
      flex: 0 0 40px;
      text-align: center;
      line-height: 50px;
      font-size: 20px;
    }
    .story {
      flex: 1;
      text-align: center;
      line-height: 50px;
      font-size: 18px;
      padding-right: 40px;
    }
  }
  .historyContent {
    padding-top: 50px;
    .tileCon {
      background-color: #fff;
      padding: 15px;
      font-size: 14px;
      span {
        color: rgb(35, 179, 130);
      }
    }
    ul {
      li {
        background-color: #fff;
        padding: 15px;
        margin-top: 1px;
        .date {
          color: #999;
          font-size: 13px;
          padding-bottom: 15px;
        }
        .hisBox {
          display: flex;
          .img {
            margin-right: 15px;
            img {
              width: 60px;
              height: 80px;
              border-radius: 4px;
            }
          }
          .hiscont {
            h1 {
              color: #333;
              font-size: 16px;
              width: 150px;
              white-space: nowrap;
              overflow: hidden;
              text-overflow: ellipsis;
            }
            p {
              padding-top: 10px;
              font-size: 12px;
              line-height: 16px;
              color: #999;
              display: -webkit-box;
              -webkit-box-orient: vertical;
              -webkit-line-clamp: 2;
              overflow: hidden;
            }
          }
        }
      }
    }
  }
  // .icon {
  //   margin: 180px auto;
  //   text-align: center;
  //   i {
  //     font-size: 100px;
  //     color: rgb(35, 179, 130);
  //   }
  //   p {
  //     font-size: 14px;
  //     margin-top: 15px;
  //   }
  // }
}
</style>